<!doctype html>
<html>
<head>
	<meta charset="utf-8"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
	<meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon-precomposed" href="../images/apple-touch-icon.png">
	<title>scrollpicker-city</title>
	<link rel="stylesheet" href="../scripts/lib/seedsui/seedsui.min.css">
</head>

<body ontouchstart="">
	<header>
		<div class="titlebar">
	        <a class="titlebar-button" href="javascript:back()">
	            <i class="icon icon-arrowleft"></i>
	        </a>
	        <h1 class="titlebar-title">地区选择器</h1>
	    </div>
	</header>
	<article>
        <div class="group" style="padding:0 8px;">
            <div class="inputbox underline">
                <input type="text" class="input-text" placeholder="请选择城市" readonly="" id="ID-City" value="江苏省-南京市-建邺区">
                <input type="hidden" value="320000-320100-320105">
                <i class="color-placeholder icon icon-position"></i>
            </div>
            <div class="inputbox">
                <input type="text" class="input-text" placeholder="请选择地区" readonly="" id="ID-Area">
                <input type="hidden" value="">
                <i class="color-placeholder icon icon-position"></i>
            </div>
        </div>
	</article>
	<!--SeedsUI-->
    <script src="../scripts/lib/seedsui/seedsui.min.js"></script>
    <!--Exmobi能力-->
    <!--<script src="../scripts/lib/exmobi/exmobi.js"></script>-->
    <script type="text/javascript">
    var view={
        /*=========================
          Model
          ===========================*/
        initialize:function(){
            /*DOM*/
            this.textCity=document.getElementById("ID-City");
            this.textArea=document.getElementById("ID-Area");
            /*Plugin*/
            this.spCity={};
            this.spArea={};
            /*Data*/

            /*Render*/
            this.render();
            
            /*Events*/
            this._attach();
        },
        render:function(){
            this._initPlugin();
        },
        /*=========================
          Plugin
          ===========================*/
        _newSpCity:function(defaults,input){
            this.spCity=new SpCity({
                //isShowArea:false,
                data:citys,
                defaultProvince:defaults.province,
                defaultCity:defaults.city,
                defaultArea:defaults.area,
                provinceClass:"text-center citycol",
                cityClass:"text-center citycol",
                areaClass:"text-center citycol",
                onClickDone:function(e){
                    input.value=e.activeValue;
                    input.nextElementSibling.value=e.activeKey;
                    e.hide();
                },
                onHid:function(e){
                    e.scrollpicker.destroy();
                }
            });
        },
        _initPlugin:function(){
            //this._initSpArea();
        },
        /*=========================
          Events
          ===========================*/
        _attach:function(e){
            var self=this;
            this.textCity.addEventListener("click",function(e){
                self._onClickTextCity(e);
            },false);
            this.textArea.addEventListener("click",function(e){
                self._onClickTextArea(e);
            },false);
        },
        /*=========================
          Event Handler
          ===========================*/
        _onClickTextCity:function(e){
            var self=this;
            var input=e.target;
            var keys=input.nextElementSibling.value.split("-");
            var defaults={
                province:keys[0]||"",
                city:keys[1]||"",
                area:keys[2]||""
            }
            this._newSpCity(defaults,input);
            setTimeout(function(){
                self.spCity.scrollpicker.show();
            },10);
        },
        _onClickTextArea:function(e){
            var self=this;
            var input=e.target;
            var keys=input.nextElementSibling.value.split("-");
            var defaults={
                province:keys[0]||"",
                city:keys[1]||"",
                area:keys[2]||""
            }
            this._newSpCity(defaults,input);
            setTimeout(function(){
                self.spCity.scrollpicker.show();
            },10);
        }
    }

    window.addEventListener("load",function(){
        view.initialize();
    }, false);

	//定义exmobi返回
	function back(){history.go(-1);}
	</script>
</body>
</html>
